home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Grafik & Text / OzTeX3.0 / PS-files / errhandler.ps < prev    next >
Text File  |  1994-01-11  |  3KB  |  85 lines

  1. %!
  2. % From: adobe!shore@su-glacier.arpa (Andrew Shore)
  3. % Date: 29 Apr 1986 2120-PDT (Tuesday)
  4. % Subject: revised PostScript downloadable error handler
  5. %
  6. % Here is our latest version of the downloadable PostScript error
  7. % handler (ehandler.ps).  When sent to any PostScript printer, it
  8. % will download itself outside the printer's "server loop"
  9. % (assuming the server loop password is correct) and redefine the
  10. % action taken on a PostScript error.
  11. %
  12. % This handler prints a sometimes-helpful summary of the error on
  13. % the thus-far-completed page and then executes the previous
  14. % handleerror code as well (which in most PostScript printers will
  15. % echo the error name and offending command over the
  16. % communications channel).  This version works on all existing
  17. % Adobe PostScript implementations.
  18. %
  19. % It really helps when debugging raw PostScript code and new
  20. % PostScript-generating applications.
  21. %
  22. % ehandler.ps -- Downloaded Error Break-page handler
  23. % Copyright (c) 1984, 1985, 1986 Adobe Systems Incorporated.
  24. % All Rights Reserved.
  25.  
  26. serverdict begin 0 exitserver
  27. (Error handler downloaded.\r) print flush
  28.  
  29. /$brkpage 64 dict def
  30. $brkpage begin
  31. /prnt
  32.  {dup type/stringtype ne{=string cvs}if dup length 6 mul/tx exch def/ty 10 def
  33.   currentpoint/toy exch def/tox exch def 1 setgray newpath
  34.   tox toy 2 sub moveto 0 ty rlineto tx 0 rlineto 0 ty neg rlineto
  35.   closepath fill tox toy moveto 0 setgray show}bind def
  36. /nl{currentpoint exch pop lmargin exch moveto 0 -10 rmoveto}def
  37. /=={/cp 0 def typeprint nl}def
  38. /typeprint{dup type dup currentdict exch known
  39.   {exec}{unknowntype}ifelse}readonly def
  40. /lmargin 72 def/rmargin 72 def
  41. /tprint{dup length cp add rmargin gt{nl/cp 0 def}if
  42.   dup length cp add/cp exch def prnt}readonly def
  43. /cvsprint{=string cvs tprint( )tprint}readonly def
  44. /unknowntype{exch pop cvlit(??)tprint cvsprint}readonly def
  45. /integertype{cvsprint}readonly def
  46. /realtype{cvsprint}readonly def
  47. /booleantype{cvsprint}readonly def
  48. /operatortype{(//)tprint cvsprint}readonly def
  49. /marktype{pop(-mark- )tprint}readonly def
  50. /dicttype{pop(-dictionary- )tprint}readonly def
  51. /nulltype{pop(-null- )tprint}readonly def
  52. /filetype{pop(-filestream- )tprint}readonly def
  53. /savetype{pop(-savelevel- )tprint}readonly def
  54. /fonttype{pop(-fontid- )tprint}readonly def
  55. /nametype{dup xcheck not{(/)tprint}if cvsprint}readonly def
  56. /stringtype
  57.  {dup rcheck{(\()tprint tprint(\))tprint}{pop(-string- )tprint}ifelse
  58.  }readonly def
  59. /arraytype
  60.  {dup rcheck{dup xcheck
  61.   {({)tprint{typeprint}forall(})tprint}
  62.   {([)tprint{typeprint}forall(])tprint}ifelse}{pop(-array- )tprint}ifelse
  63.  }readonly def
  64. /packedarraytype
  65.  {dup rcheck{dup xcheck
  66.   {({)tprint{typeprint}forall(})tprint}
  67.   {([)tprint{typeprint}forall(])tprint}ifelse}{pop(-packedarray- )tprint}ifelse
  68.  }readonly def
  69. /courier/Courier findfont 10 scalefont def
  70. /OLDhandleerror errordict /handleerror get def
  71. end %$brkpage
  72.  
  73. errordict/handleerror
  74.  {systemdict begin $error begin $brkpage begin newerror
  75.    {/newerror false store
  76.     vmstatus pop pop 0 ne{grestoreall}if initgraphics courier setfont
  77.     lmargin 720 moveto(ERROR: )prnt errorname prnt
  78.     nl(OFFENDING COMMAND: )prnt/command load prnt
  79.     $error/ostack
  80.     known{nl nl(STACK:)prnt nl nl $error/ostack get aload length{==}repeat}if
  81.     systemdict/showpage get exec
  82.     /newerror true store/OLDhandleerror load end end end exec}{end end end}
  83.   ifelse}
  84. dup 0 systemdict put dup 4 $brkpage put bind readonly put
  85.